package net.zisen.cloud.goods.fallback;

import feign.hystrix.FallbackFactory;
import net.zisen.cloud.base.msg.ResultMsg;
import net.zisen.cloud.goods.client.GoodsClient;
import net.zisen.cloud.goods.model.Goods;
import org.springframework.stereotype.Component;

/**
 * @author tim/278002989@qq.com
 * @Classname GoodsClientFallbackFactory
 * @Description TODO
 * @Date 2019-05-17 17:42
 */
@Component
public class GoodsClientFallbackFactory implements FallbackFactory<GoodsClient> {
    @Override
    public GoodsClient create(Throwable throwable) {
        return new GoodsClient() {

            /**
             * 更新库存
             *
             * @param goodsId
             * @param quality
             * @return
             */
            @Override
            public ResultMsg updateQuality(Long goodsId, Integer quality) {
                return ResultMsg.fail().resultMsg("更新商品库存失败");
            }

            /**
             * 获取商品信息
             *
             * @param goodsId
             * @return
             */
            @Override
            public ResultMsg<Goods> goodsDetail(Long goodsId) {
                return null;
            }
        };
    }
}
